<<<<<<< HEAD
ny_local =
read_csv("./data/ny_local.csv")
## Parsed with column specification:
## cols(
## .default = col_character(),
## year = col_double(),
## data_value = col_double(),
## low_confidence_limit = col_double(),
## high_confidence_limit = col_double(),
## population_count = col_double(),
## city_fips = col_double(),
## tract_fips = col_double()
=======
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2 ✓ purrr 0.3.4
## ✓ tibble 3.0.3 ✓ dplyr 1.0.2
## ✓ tidyr 1.1.2 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.5.0
## ── Conflicts ────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(flexdashboard)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
ny_local =
read_csv("./data/500_Cities.csv") %>%
janitor::clean_names() %>%
filter(state_abbr == "NY")
## Parsed with column specification:
## cols(
## .default = col_character(),
## Year = col_double(),
## Data_Value = col_double(),
## Low_Confidence_Limit = col_double(),
## High_Confidence_Limit = col_double(),
## PopulationCount = col_double()
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
## )
## See spec(...) for full column specifications.
covid_symptom_df =
read_csv("./data/Anxiety_Depression.csv") %>%
janitor::clean_names() %>%
filter(state == "New York") %>%
mutate(
indicator_id = case_when(
indicator == "Symptoms of Anxiety Disorder" ~ "Anxiety",
indicator == "Symptoms of Anxiety Disorder or Depressive Disorder" ~ "Anxiety/Depressive",
indicator == "Symptoms of Depressive Disorder" ~ "Depressive"
))
## Parsed with column specification:
## cols(
## Phase = col_double(),
## Indicator = col_character(),
## Group = col_character(),
## State = col_character(),
## Subgroup = col_character(),
## `Time Period` = col_double(),
## `Time Period Label` = col_character(),
## Value = col_double(),
## `Low CI` = col_double(),
## `High CI` = col_double(),
## `Confidence Interval` = col_character(),
## `Quartile range` = col_character()
## )
mental_care_df =
read_csv("./data/Mental_Health_Care.csv") %>%
janitor::clean_names() %>%
filter(state == "New York") %>%
mutate(
indicator_id = case_when(
indicator == "Needed Counseling or Therapy But Did Not Get It, Last 4 Weeks" ~ "No Therapy",
indicator == "Received Counseling or Therapy, Last 4 Weeks" ~ "Therapy",
indicator == "Took Prescription Medication for Mental Health And/Or Received Counseling or Therapy, Last 4 Weeks" ~ "Med/Therapy",
indicator == "Took Prescription Medication for Mental Health, Last 4 Weeks" ~ "Med"
)
)
## Parsed with column specification:
## cols(
## Indicator = col_character(),
## Group = col_character(),
## State = col_character(),
## Subgroup = col_character(),
## Phase = col_double(),
## `Time Period` = col_double(),
## `Time Period Label` = col_character(),
## Value = col_double(),
## LowCI = col_double(),
## HighCI = col_double(),
## `Confidence Interval` = col_character(),
## `Quartile Range` = col_character(),
## `Suppression Flag` = col_double()
## )
<<<<<<< HEAD
=======
chronic_df =
read_csv("./data/Chronic_Disease_Indicators.csv") %>%
janitor::clean_names()
## Parsed with column specification:
## cols(
## .default = col_character(),
## YearStart = col_double(),
## YearEnd = col_double(),
## Response = col_logical(),
## DataValue = col_double(),
## DataValueAlt = col_double(),
## LowConfidenceLimit = col_double(),
## HighConfidenceLimit = col_double(),
## StratificationCategory2 = col_logical(),
## Stratification2 = col_logical(),
## StratificationCategory3 = col_logical(),
## Stratification3 = col_logical(),
## ResponseID = col_logical(),
## StratificationCategoryID2 = col_logical(),
## StratificationID2 = col_logical(),
## StratificationCategoryID3 = col_logical(),
## StratificationID3 = col_logical()
## )
## See spec(...) for full column specifications.
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
write_csv(ny_local, "./data/ny_local.csv")
Page 1
Column
Chart 1
ub_overall_plot =
ny_local %>%
select(category, measure_id, data_value) %>%
filter(category == "Unhealthy Behaviors") %>%
ggplot(aes(x = measure_id, y = data_value, color = measure_id)) +
geom_boxplot() +
labs(
x = "Unhealthy Behavior",
y = "Prevalence (%)"
) +
scale_y_continuous(limits = c(0, 100))
ggplotly(ub_overall_plot)
## Warning: Removed 140 rows containing non-finite values (stat_boxplot).
<<<<<<< HEAD
=======
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
Column
Chart 2
mental_health_value =
ny_local %>%
select(unique_id, data_value, measure_id, population_count) %>%
filter(measure_id == "MHLTH") %>%
mutate(value_mental = data_value) %>%
select(unique_id, value_mental, population_count)
current_smoking_value =
ny_local %>%
select(unique_id, data_value, measure_id, population_count) %>%
filter(measure_id == "CSMOKING") %>%
mutate(value_smoking = data_value) %>%
select(unique_id, value_smoking, population_count)
mental_smoking =
<<<<<<< HEAD
left_join(mental_health_value, current_smoking_value) %>%
drop_na()
=======
left_join(mental_health_value, current_smoking_value)
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
## Joining, by = c("unique_id", "population_count")
current_smoking_plot =
mental_smoking %>%
ggplot(aes(x = value_mental, y = value_smoking, size = population_count)) +
geom_point(alpha = 0.5, color = "steel blue") +
labs(
x = "Mental Health Prevalence (%)",
y = "Unhealthy Behavior Prevalence (%)",
title = "Current Smoking"
) +
scale_y_continuous(limits = c(0, 100))
ggplotly(current_smoking_plot)
<<<<<<< HEAD
r_smoking = cor(mental_smoking$value_mental, mental_smoking$value_smoking, method = c("pearson"))
r_smoking
## [1] 0.9487768
=======
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
Chart 3
binge_drinking_value =
ny_local %>%
select(unique_id, data_value, measure_id) %>%
filter(measure_id == "BINGE") %>%
mutate(value_binge_drinking = data_value) %>%
select(unique_id, value_binge_drinking)
binge_drinking =
left_join(mental_health_value, binge_drinking_value)
## Joining, by = "unique_id"
binge_drinking_plot =
binge_drinking %>%
ggplot(aes(x = value_mental, y = value_binge_drinking, size = population_count)) +
geom_point(alpha = 0.5, color = "darkorchid4") +
labs(
x = "Mental Health Prevalence (%)",
y = "Unhealthy Behavior Prevalence (%)",
title = "Binge Drinking"
) +
scale_y_continuous(limits = c(0, 100))
ggplotly(binge_drinking_plot)
<<<<<<< HEAD
=======
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
Chart 4
physical_inactivity_value =
ny_local %>%
select(unique_id, data_value, measure_id) %>%
filter(measure_id == "LPA") %>%
mutate(value_physical_inactive = data_value) %>%
select(unique_id, value_physical_inactive)
physical_inactivity =
left_join(mental_health_value, physical_inactivity_value)
## Joining, by = "unique_id"
physical_inactivity_plot =
physical_inactivity %>%
ggplot(aes(x = value_mental, y = value_physical_inactive, size = population_count)) +
geom_point(alpha = 0.5, color = "darkcyan") +
labs(
x = "Mental Health Prevalence (%)",
y = "Unhealthy Behavior Prevalence (%)",
title = "Physical Inactivity"
) +
scale_y_continuous(limits = c(0, 100))
ggplotly(physical_inactivity_plot)
<<<<<<< HEAD
=======
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
Chart 5
obesity_value =
ny_local %>%
select(unique_id, data_value, measure_id) %>%
filter(measure_id == "OBESITY") %>%
mutate(value_obesity = data_value) %>%
select(unique_id, value_obesity)
obesity =
left_join(mental_health_value, obesity_value)
## Joining, by = "unique_id"
obesity_plot =
obesity %>%
ggplot(aes(x = value_mental, y = value_obesity, size = population_count)) +
geom_point(alpha = 0.5, color = "chartreuse4") +
labs(
x = "Mental Health Prevalence (%)",
y = "Unhealthy Behavior Prevalence (%)",
title = "Obesity"
) +
scale_y_continuous(limits = c(0, 100))
ggplotly(obesity_plot)
<<<<<<< HEAD
=======
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
Chart 6
sleep_value =
ny_local %>%
select(unique_id, data_value, measure_id) %>%
filter(measure_id == "SLEEP") %>%
mutate(value_sleep = data_value) %>%
select(unique_id, value_sleep)
sleep =
left_join(mental_health_value, sleep_value)
## Joining, by = "unique_id"
sleep_plot =
sleep %>%
ggplot(aes(x = value_mental, y = value_sleep, size = population_count)) +
geom_point(alpha = 0.5, color = "darkgoldenrod2") +
labs(
x = "Mental Health Prevalence (%)",
y = "Unhealthy Behavior Prevalence (%)",
title = "Sleep < 7 hours"
) +
scale_y_continuous(limits = c(0, 100))
ggplotly(sleep_plot)
<<<<<<< HEAD
=======
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
Page 2
Column
Chart 1
prevention_plot =
ny_local %>%
filter(category == "Prevention") %>%
group_by(measure_id) %>%
ggplot(aes(x = measure_id, y = data_value, color = measure_id)) +
geom_boxplot() +
labs(
x = "Prevention",
y = "Prevalence (%)") +
theme(axis.text.x = element_text(angle = 60, hjust = 1)) +
scale_y_continuous(limits = c(0, 100))
ggplotly(prevention_plot)
## Warning: Removed 226 rows containing non-finite values (stat_boxplot).
<<<<<<< HEAD
=======
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
Column
Chart 2
mental_health_df =
ny_local %>%
select(unique_id, data_value, measure_id, population_count) %>%
filter(measure_id == "MHLTH") %>%
mutate(value_mental = data_value) %>%
select(unique_id, value_mental, population_count)
checkup_df =
ny_local %>%
select(unique_id, data_value, measure_id) %>%
filter(measure_id == "CHECKUP") %>%
mutate(value_checkup = data_value) %>%
select(unique_id, value_checkup)
mental_checkup =
left_join(mental_health_df, checkup_df)
## Joining, by = "unique_id"
mental_checkup_plot =
mental_checkup %>%
ggplot(aes(x = value_mental, y = value_checkup, size = population_count)) +
<<<<<<< HEAD
geom_point(alpha = 0.5, color = "steel blue") +
=======
geom_point(color = "steel blue") +
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
labs(title = "Current Annual Checkup",
x = 'Mental Health Prevalence (%)',
y = 'Prevention Prevalence (%)') +
scale_y_continuous(limits = c(0, 100))
ggplotly(mental_checkup_plot)
<<<<<<< HEAD
=======
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
Chart 3
insurance_df =
ny_local %>%
select(unique_id, data_value, measure_id, population_count) %>%
filter(measure_id == "ACCESS2") %>%
mutate(value_insurance = data_value) %>%
select(unique_id, value_insurance, population_count)
mental_insurance =
left_join(mental_health_df, insurance_df)
## Joining, by = c("unique_id", "population_count")
mental_insurance_plot =
mental_insurance %>%
ggplot(aes(x = value_mental, y = value_insurance, size = population_count)) +
<<<<<<< HEAD
geom_point(alpha = 0.5, color = "chartreuse4") +
=======
geom_point(color = "chartreuse4") +
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
labs(title = "Current Lack of Insurance",
x = "Mental Health Prevalence (%)",
y = "Prevention Prevalence (%)") +
scale_y_continuous(limits = c(0, 100))
ggplotly(mental_insurance_plot)
<<<<<<< HEAD
=======
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
Page 3
Row
Chart 1
anxiety_depression_plot =
covid_symptom_df %>%
ggplot(aes(x = time_period, y = value, color = indicator_id)) +
geom_point() +
geom_line() +
scale_x_continuous(
limits = c(1, 18),
breaks = seq(1, 18, 1)
) +
labs(
x = "Time (week)",
y = "Percentage"
)
ggplotly(anxiety_depression_plot)
<<<<<<< HEAD
=======
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
Row
Chart 2
mental_care_plot =
mental_care_df %>%
ggplot(aes(x = time_period, y = value, color = indicator_id)) +
geom_point() +
geom_line() +
labs(
x = "Time (week)",
y = "Percentage"
)
ggplotly(mental_care_plot)
<<<<<<< HEAD
=======
>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d
treatment_plot =
mental_care_df %>%
ggplot(aes(x = indicator_id, y = value, color = indicator_id)) +
geom_boxplot() +
labs(
x = "Treatment",
y = "Percentage"
)
ggplotly(treatment_plot)
<<<<<<< HEAD
=======
unhealthy_days_mean_plot =
chronic_df %>%
drop_na(data_value) %>%
mutate(year = year_start) %>%
filter(question == "Recent mentally unhealthy days among adults aged >= 18 years") %>%
group_by(year) %>%
summarise(
mean_of_mentally_unhealthy_days = mean(data_value)
) %>%
ggplot(aes(x = year, y = mean_of_mentally_unhealthy_days, color = year)) +
geom_point() +
geom_line() +
scale_x_continuous(
breaks = c(2011,2012,2013,2014,2015,2016,2017,2018)) +
labs(
title = "The average mentally unhealthy days for American adults from 2011 to 2018",
x = "Year",
y = "The average mentally unhealthy days")
## `summarise()` ungrouping output (override with `.groups` argument)
unhealthy_days_mean_plot

>>>>>>> c39ca86df3e1516e8c6788dba9336907f1464f4d